import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import get from '@dfeidao/atom-web/local/get';
import fire_component_msg from '@dfeidao/atom-web/msg/fire';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import error from '@dfeidao/atom-web/msgbox/error';
import success from '@dfeidao/atom-web/msgbox/success';
// import _hide from '@dfeidao/atom-web/ui/hide';
// import show_loading from '../../atom-web/show-loading';
// import hide_loading from '../../atom-web/hide-loading';
export default async function a002(fd: IFeidaoAiBrowserComponent) {
	// 保存
	const fid = fd.data.node.querySelector<HTMLInputElement>('#fid').value;
	const ftitle = fd.data.node.querySelector<HTMLInputElement>('#ftitle').value;
	const ftype = fd.data.node.querySelector<HTMLInputElement>('#ftype').value;
	const id = get(fd, 'id');
	const productid = get(fd, 'productid');

	if (!fid) {
		await error('请完善字段');
		// fire_component_msg('zjc-000001', 'ec-001', 'please', '请完善字段');
		return;
	}
	if (!ftitle) {
		await error('请完善字段标题');
		// fire_component_msg('zjc-000001', 'ec-001', 'please', '请完善字段标题');
		return;
	}
	const query = {
		field: fid,
		fieldtitle: ftitle,
		fieldtype: ftype,
		_id: id,
		productid
	};
	// show_loading();
	const tab = "tab3";
	// const res = await nodejs(url, './permissions/role_type_upd2', query, false, false);
	const res = await nodejs('role-type/zj-000008/s001', query);
	// hide_loading();
	if (res === 'success') {
		await success('修改成功');
		// fire_component_msg('zjc-000001', 'ec-001', 'success', '修改成功');
		fire_component_msg('zj-000004', 'ec-002', tab);
		fd.data.node.classList.add('display-n');
	} else {
		await error('修改失败');
		// fire_component_msg('zjc-000001', 'ec-001', 'fail', '修改失败');
	}
}
